<template>
	<view class="bg-gray" style="height: 100vh;">
		<cu-custom :bgColor="NavBarColor" :isBack="true" backFlag="navigate">
			<block slot="backText">返回</block>
			<block slot="content">入库单详情</block>
		</cu-custom>
		<view class="incoming_Body">
			<view class="incoming_One">
				<view class="inner_One">
					<view class="indetail_row">
						<view class="row_text">单据编号:</view>
						<view class="text-lg">{{incomingItem.billNo}}</view>
					</view>
					<view class="indetail_row">
						<view class="row_text">采购订单:</view>
						<view class="text-blue">{{incomingItem.srcNo}}</view>
					</view>
					<view class="indetail_row">
						<view class="row_text">单据日期:</view>
						<view class="row_message">{{incomingItem.createTime}}</view>
					</view>
					<view class="indetail_between">
						<view class="indetail_row">
							<view class="row_text">供应商:</view>
							<view class="row_message">{{incomingItem.supplierId_dictText}}</view>
						</view>
						<view class="indetail_row">
							<view class="row_text">发票类型:</view>
							<view class="row_message">{{incomingItem.invoiceType_dictText}}</view>
						</view>
					</view>
					<view class="indetail_between">
						<view class="indetail_row">
							<view class="row_text">业务部门:</view>
							<view class="row_message">{{incomingItem.opDept_dictText}}</view>
						</view>
						<view class="indetail_row">
							<view class="row_text">业务员:</view>
							<view class="row_message">{{incomingItem.operator_dictText}}</view>
						</view>
					</view>
					<view class="indetail_between">
						<view class="indetail_row">
							<view class="row_text">入库金额:</view>
							<view class="text-df margin-left2 text-orange">{{incomingItem.cost}}</view>
						</view>
						<view class="indetail_row">
							<view class="row_text">制单人:</view>
							<view class="row_message">{{incomingItem.createBy_dictText}}</view>
						</view>
						<view class="indetail_row">
							<view class="row_text">单据阶段:</view>
							<view class="row_message">{{incomingItem.billStage_dictText}}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="incoming_Two">
				<view class="intwo_row">
					<view class="incoming_Title" v-for="(item,index) in incomingTArray" :key="index"
						:class="tabIndex==index?'incoming_sel':'incoming_nor'" @click="selAction(index)">{{item}}</view>
				</view>
				<view class="bottom_line"></view>
				<swiper class="flex-bottom-swiper" @change="swiperChange" :current="tabIndex">
					<swiper-item class="flex-swiper-item">
						<view class="inner_One" v-for="(item,index) in queryEntryByMainList" :key="index">
							<view class="intwo_row">
								<view class="row_text">源单分录号:</view>
								<view class="text-blue">{{item.srcNo}}</view>
							</view>
							<view class="intwo_row">
								<view class="row_text">物料:</view>
								<view class="row_message">{{item.materialId_dictText}}</view>
							</view>
							<view class="intwo_row">
								<view class="row_text">规格型号:</view>
								<view class="row_message">{{item.materialModel}}</view>
							</view>
							<view class="indetail_between">
								<view class="intwo_row">
									<view class="row_text">仓库:</view>
									<view class="row_message">{{item.warehouseId_dictText}}</view>
								</view>
								<view class="intwo_row">
									<view class="row_text">批次:</view>
									<view class="row_message">{{item.batchNo}}</view>
								</view>
							</view>
							<view class="indetail_between">
								<view class="intwo_row">
									<view class="row_text">结算数量:</view>
									<view class="text-df margin-left2 text-blue">{{item.settleQty}}</view>
								</view>
								<view class="intwo_row">
									<view class="row_text">单位:</view>
									<view class="row_message">{{item.unitId_dictText}}</view>
								</view>
							</view>
							<view class="indetail_between">
								<view class="intwo_row">
									<view class="row_text">入库数量:</view>
									<view class="text-df margin-left2 text-blue">{{item.qty}}</view>
								</view>
								<view class="intwo_row">
									<view class="row_text">结算金额:</view>
									<view class="text-df margin-left2 text-orange">{{item.settleAmt}}</view>
								</view>
							</view>
						</view>
					</swiper-item>
					<swiper-item class="flex-swiper-item">
						<view class="inner_One" v-for="(item,index) in purchaseEntryByMainList" :key="index">
							<view class="intwo_row">
								<view class="row_text">源单分录号:</view>
								<view class="text-blue">{{item.srcNo}}</view>
							</view>
							<view class="intwo_row">
								<view class="row_text">物料:</view>
								<view class="row_message">{{item.materialId_dictText}}</view>
							</view>
							<view class="intwo_row">
								<view class="row_text">规格型号:</view>
								<view class="row_message">{{item.materialModel}}</view>
							</view>
							<view class="indetail_between">
								<view class="intwo_row">
									<view class="row_text">入库数量:</view>
									<view class="text-df margin-left2 text-blue">{{item.qty}}</view>
								</view>
								<view class="intwo_row">
									<view class="row_text">单位:</view>
									<view class="row_message">{{item.unitId_dictText}}</view>
								</view>
							</view>
							<view class="indetail_between">
								<view class="intwo_row">
									<view class="row_text">含税单价:</view>
									<view class="text-df margin-left2 text-blue">{{item.price}}</view>
								</view>
								<view class="intwo_row">
									<view class="row_text">含税金额:</view>
									<view class="text-df margin-left2 text-orange">{{item.amt}}</view>
								</view>
							</view>
						</view>
					</swiper-item>
				</swiper>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				NavBarColor: this.NavBarColor,
				incomingItem: {
					id: "",
					cost: "",
					srcNo: "",
					billNo: "",
					createTime: "",
					opDept_dictText: "",
					operator_dictText: "",
					createBy_dictText: "",
					billStage_dictText: "",
					supplierId_dictText: "",
					invoiceType_dictText: "",
				},
				tabIndex: 0,
				purchaseEntryByMainList: [],
				queryEntryByMainList: [],
				incomingTArray: ['入库单明细', '采购订单明细']
			}
		},
		onLoad: function(option) {
			console.log("incomingDetail==onLoad>>")
			this.incomingItem = JSON.parse(decodeURIComponent(option.item));
			console.log("incomingItem", this.incomingItem)
			this.queryEntryByMainId(this.incomingItem.id);
			this.purchaseEntryByMainId(this.incomingItem.srcBillId);
		},
		created() {
			console.log("created==>>")
		},
		methods: {
			selAction(index) {
				this.tabIndex = index
			},
			purchaseEntryByMainId(itemID) {
				console.log("purchaseEntryByMainId")
				this.$http.get('/purchase/purOrder/queryEntryByMainId/dictText?id=' + itemID).then(res => {
					if (res.data.success) {
						console.log("result", res.data.result)
						this.purchaseEntryByMainList = res.data.result
					}
				})
			},
			queryEntryByMainId(itemID) {
				console.log("queryEntryByMainId")
				this.$http.get('/stock/stkIo/queryEntryByMainId/dictText?id=' + itemID).then(res => {
					if (res.data.success) {
						console.log("result", res.data.result)
						this.queryEntryByMainList = res.data.result
					}
				})
			},
			swiperChange(e) {
				console.log("swiperChange==>>", e.detail.current)
				this.tabIndex = e.detail.current
			},
		}
	}
</script>

<style>
	.incoming_Body {
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	.incoming_One {
		width: 100%;
		display: flex;
		background-color: white;
	}

	.inner_One {
		width: 92%;
		margin: 4%;
		display: flex;
		flex-direction: column;
		border: 1rpx solid #FAF0E6;
		border-radius: 16rpx;
		background-color: white;
		padding: 16rpx;
		box-shadow: 0px 0px 10px 0px rgba(111, 118, 151, 0.1);
	}

	.incoming_Two {
		width: 100%;
		min-height: 56vh;
		margin-top: 16rpx;
		background-color: white;
	}

	.indetail_row {
		width: 100%;
		display: flex;
		padding: 8rpx 16rpx;
		align-items: center;
	}

	.intwo_row {
		display: flex;
		padding: 8rpx 16rpx;
		align-items: center;
	}

	.indetail_between {
		display: flex;
		justify-content: space-between;
	}

	.indetail_end {
		display: flex;
	}

	.row_text {
		margin: 4rpx;
		font-size: 24rpx;
		color: #8799a3;
	}

	.row_message {
		margin: 4rpx;
		font-size: 24rpx;
	}

	.incoming_Title {
		display: flex;
		margin: 12rpx 24rpx;
	}

	.incoming_nor {
		font-size: 24rpx;
		color: grey;
	}

	.incoming_sel {
		font-weight: bold;
		font-size: 32rpx;
		color: black;
	}

	.bottom_line {
		width: 96%;
		margin-left: 2%;
		height: 2rpx;
		background-color: #FAF0E6;
	}

	.flex-bottom-swiper {
		width: 100%;
		height: 64vh;
	}

	.flex-swiper-item {
		width: 100%;
		height: 64vh;
		display: flex;
		flex-direction: column;
		overflow-y: scroll;
	}
	.margin-left2{
		margin-left: 4rpx;
	}
</style>
